<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/17
 * Time: 19:14
 */

namespace App\Http\Model;


class TempPhone extends CommonModel {

    protected $table      = 'temp_phone';
    protected $primaryKey = 'TpId';
    public $timestamps    = false;
    protected $fillable   = ['TpPhone','TpCode','TpDeadline'];

    public function __construct(array $attributes=[]) {
        parent::__construct($attributes);
    }

    public function getLastDataByPhone($phone) {
        return self::where('TpPhone',$phone)->orderBy('TpId','desc')->first();
    }

    public function addNewData($phoneNum,$code) {
        $this->TpPhone    = $phoneNum;
        $this->TpCode     = $code;
        $this->TpDeadline = date('Y-m-d H-i-s',time()+ 60);
        return $this->save();
    }
}